1
2 #include<stdio.h>
3 #include<stdlib.h>
4 #include<conio.h>
5 #include<string.h>
6 #include<windows.h>
7 #include<time.h>
8
9
10 ///Logic Functions
11
12 /// Update & Insert Function
13 void insertfirst(int data, char foodname[25], int quantity, float price);
14 void insertmid(int pos, int data, char foodname[25], int quantity, float price);
15 void insertend(int data, char foodname[25], int quantity, float price);
16 void updatefood(int udata, int uquantity);
17
18 /// Display Function
19 void foodlist();
20 void order_view(int order, int quantity, int or_no);
21 void main_menu();
22
23 ///Delete & Count Function
24 void deletefood(int serial);
25 int countitem();
26
27
28
29
30 ///extra design Function
31
32 void cls();
33 void echo(char print[]);
34 void br(int line);
35 void pre(int tab);
36 void span(int space);
37 void ccolor(int clr);
38 void pwellcome();
39 void loadingbar();
40 void middle1(void);
41 void middtab1(void);
42 void backuploader(void);
43
44
45 ///START Structure Here
46
47 struct Node{
48
49 char foodname[50];
50 int quantity;
51 float price;
52 int data;
53 struct Node *next;
54
55 };
56
57 ///Global Type
58
59 typedef struct Node node ;
60
61 node *head, *list;
62
63 int main(){
64
65 system("title Simple Order System");
66 system("mode con: cols=88 lines=30");
67
68
69 loadingbar(); cls();
70 pwellcome();
71 Sleep(300);
72 cls();
73
74 int c=0; int any;
75 int cardno[100];
76 float cardmoney[100];
77 float totalmoney = 0;
78 int total_order[100];
79 int order_quantity[100];
80 int order=0;
81 int uquantity;
82 int citem;
83
84 head = NULL;
85 insertfirst(5,"Cakes",23,120.23);
86 insertend(6,"Mo:Mo ",13,100.67);
87 insertend(1,"Pasta",8,720.83);
88 insertend(2,"Coffee ",46,70.23);
89 insertend(3,"Frech Fries ",46,70.23);
90 insertend(4,"Chicken Tandoori ",34,60.23);
91 insertend(7,"Chocolate Ice cream",7,520.29);
92 insertend(8,"Grain Breads",121,35.13);
93 insertend(9,"Cold drinks",73,20.13);
94
95
96
97 mainmenu:
98 br(1);
99
100 main_menu();
101
102 int main_menu_choice;
103
104 br(1); pre(4); fflush(stdin); scanf("%d",&main_menu_choice);
105
106 if((main_menu_choice >=1 && main_menu_choice <=3)){
107
108 if(main_menu_choice == 1){
109
110 foodlist:
111
112 cls();
113 printf("=> 0. Main Menu ");
114 foodlist();
115
116
117 }
118
119 else if( main_menu_choice == 2){
120
121 adminpanelchoice:
122
123 int admin_panel_choice;
124
125 cls(); middle1() ; pre(4); printf("1. Main Menu\n\n\t"); Sleep(300);
126 printf("Please Enter Password or ( 1 to Back in Main Menu ) : ");
127
128
129 fflush(stdin); scanf("%d",&admin_panel_choice);
130
131 if(admin_panel_choice==1234567){
132
133
134
135 node *temp;
136
137 temp = list;
138
139 adminchoise:
140
141 cls(); br(3); pre(4); echo(">>>> Admin Panel <<<< \n\n");
142 pre(4);
143 printf(" 1. Total Cash Today \n\n");Sleep(250);pre(4);
144 printf(" 2. View Card Pay \n\n");Sleep(250);pre(4);
145 printf(" 3. Add Item \n\n");Sleep(250);pre(4);
146 printf(" 4. Delete Item \n\n");Sleep(250);pre(4);
147 printf(" 5. Instant Item List \n\n");Sleep(250);pre(4);
148 printf(" 6. Item Counter \n\n");Sleep(250);pre(4);
149 printf(" 7. Backup System\n\n");Sleep(250);pre(4);
150 printf(" 8. Instant Order Preview\n\n");Sleep(250);pre(4);
151 printf(" 0. Main Menu \n\n");
152 printf("Enter Your From 1-0: ");
153 Sleep(250);
154
155 int adminchoise;
156
157
158
159 fflush(stdin); scanf("%d",&adminchoise);
160
161 if(adminchoise==1){
162
163 cls(); middle1(); pre(4); printf("Todays Total Cash : %0.2f \n",totalmoney);
164
165 Sleep(2000);
166
167 goto adminchoise;
168 }
169 else if(adminchoise==2){
170
171 if(c!=0){
172
173 cls(); br(3); pre(4);
174
175 printf(" ____________________________\n");pre(4);
176 printf("| Card NO. | Money $ |\n");pre(4);
177 printf("------------------------------\n");pre(4);
178
179 for(int z=1; z<=c;z++){
180
181 printf("| %d | %0.2f |\n",cardno[z],cardmoney[z]);pre(4);
182 printf("------------------------------\n");pre(4);
183 Sleep(150);
184
185 }
186 Sleep(1500);
187 }
188
189 if(c==0){
190
191 cls(); middle1(); pre(4);
192 printf("No Card History\n");}
193 Sleep(1500);
194 goto adminchoise;
195 }
196
197 else if(adminchoise==3){
198
199 foodadd:
200 cls();
201
202 char ffoodname[25];
203 int fquantity;
204 int fdata;
205 float fprice;
206 int fposi;
207
208
209 br(3);pre(4); printf(" Enter Food Item Name : ");
210
211 fflush(stdin); scanf("%[^\n]s",ffoodname);
212 fquantity:
213 fflush(stdin);
214
215 br(2);pre(4);
216 printf(" Enter Item Quantity : ");
217
218 scanf("%d",&fquantity); fflush(stdin);
219
220 foodserial:
221 br(2);pre(4); printf(" Enter Item Serial : ");
222 scanf("%d",&fdata);
223 node *exist;
224 exist = list;
225 while(exist->data!=fdata){
226 if(exist->next==NULL){
227 break;
228 }
229 exist=exist->next;
230 }
231 if(exist->data==fdata){
232 cls(); br(5);pre(3); printf(" Food Serial Already Exist, Please Re-Enter "); Sleep(2000);
233 goto foodserial;
234 }
235
236 fprice:
237 fflush(stdin);
238
239 br(2);pre(4); printf(" Enter Item Price : ");fflush(stdin);
240
241 scanf("%f",&fprice);
242
243
244
245 br(2);pre(4); printf("Submitting your data");for(int cs=0;cs<4;cs++){printf(" .");Sleep(500);}
246
247
248 insertend(fdata,ffoodname,fquantity,fprice);
249
250 br(2);pre(4); printf("Adding Item Successfull.......\n");
251
252 Sleep(2000);
253
254 goto adminchoise;
255
256 }
257 else if(adminchoise==4){
258
259 cls();
260 middle1();pre(2);
261 printf("Enter Serial No of the Item To Delete : ");
262 fdelete:
263 int fdelete;
264 fflush(stdin); scanf("%d",&fdelete);
265 node *temp;
266 temp=list;
267 while(temp->data != fdelete){
268 temp = temp->next;
269 }
270 if(temp->data==fdelete){
271 deletefood(fdelete);
272 }
273 else{
274 br(2); pre(2); printf("Please Enter Correct Number : "); Sleep(500);
275 goto fdelete;
276 }
277
278
279 goto adminchoise;
280 }
281
282 else if(adminchoise==5){
283
284 cls(); foodlist(); Sleep(1000);
285
286 br(2);pre(4); printf("1. <-- back \n\n");pre(5);
287
288
289
290 fflush(stdin); scanf("%d",&any);
291
292 goto adminchoise;
293
294 }
295
296 else if(adminchoise==6){
297
298 citem = countitem();
299 cls();
300 for(int cs=1;cs<=citem;cs++){
301 middle1(); pre(4);
302 printf("Item Counting ");
303 printf(" %d ",cs);
304 Sleep(150);
305 cls();
306 }
307 cls();
308 middle1();pre(4);
309 printf("Total Item Item is --> %d \n",citem); Sleep(2000);
310 goto adminchoise;
311
312 }
313
314 ///Backup System
315 else if(adminchoise==7){
316
317
318 char date[35]=__DATE__;
319
320 strcat(date,".txt");
321 FILE *fptr;
322 fptr=fopen(date,"w");
323 backuploader();
324 if(fptr==NULL){
325 br(3); pre(3); printf("Error!"); Sleep(500);
326 goto adminchoise;
327 }
328 fprintf(fptr,"Total Cash Today : %0.2f\n\n\n",totalmoney);
329 fprintf(fptr,"Card No ------- Money \n\n");
330 for(int l=1; l<=c;l++){
331 fprintf(fptr,"%d ------- %0.2f \n",cardno[l],cardmoney[l]);
332 }
333 br(2);pre(4); printf("Backup Successfull..."); Sleep(1500);
334
335
336
337 fclose(fptr);
338 goto adminchoise;
339 }
340 else if(adminchoise==8){
341
342 cls();br(2);pre(2);
343 ccolor(26);
344 printf("\n\t\t"); ccolor(240);
345 printf("______________________________________________________ "); ccolor(26);
346 printf("\n\t\t"); ccolor(240);
347 printf("| Order No. | Item Name | Quantity | In Stock |"); ccolor(26);
348 printf("\n\t\t"); ccolor(240);
349 printf("------------------------------------------------------"); ccolor(26);
350 for(int o=1;o<=order;o++){
351 order_view(total_order[o],order_quantity[o],o);
352 }
353
354 br(2);pre(4); printf("1. <-- back \n\n");pre(5);
355
356 fflush(stdin); scanf("%d",&any);
357
358 goto adminchoise;
359
360
361
362 }
363 else if(adminchoise==0){
364
365 goto mainmenu;
366 }
367
368 else{
369 br(2); pre(4); printf("Please Select From List : "); Sleep(500);
370 goto adminchoise;
371 }
372
373
374
375 }
376
377 else if(admin_panel_choice==1){
378 goto mainmenu;
379 }
380 else{
381 br(2); pre(4); printf("Please Enter Correct Choice");
382 goto adminpanelchoice;
383 }
384
385 }
386
387 else if(main_menu_choice==3){
388 cls();
389 middle1(); pre(3); printf("Thank You For Using Our System. \n\t\t\tBrought To You By code-projects.org \n\n\n\n\n\n\n");
390 Sleep(1000);
391
392 exit(1);
393
394 }
395
396 }
397 else{
398 br(2); pre(4); printf("Please Enter Correct Choice"); Sleep(300);
399 goto mainmenu;
400 }
401
402
403 int get_food_choice;
404
405
406 br(2); pre(3);fflush(stdin);
407 printf("Place Your Order: ") ;
408 scanf("%d",&get_food_choice);
409
410 if(get_food_choice==0){
411 goto mainmenu;
412 }
413
414 node *temp;
415
416 temp = list ;
417
418 while(temp->data != get_food_choice){
419
420 temp = temp->next;
421 if(temp==NULL){
422 br(2); pre(4); echo("Please Choice From List: "); br(2); Sleep(1000);
423 goto foodlist;
424 }
425
426 }
427 if(get_food_choice == temp->data){
428
429 fcquantity:
430 br(2); pre(4);
431 printf("Enter Item Quantity : ");
432
433 int fcquantity;
434
435 fflush(stdin); scanf("%d",&fcquantity); cls();
436
437
438
439 if(fcquantity==0){
440 cls(); middle1();pre(3); printf("Quantity Can not be Zero "); Sleep(2000);
441 cls();
442 goto foodlist;
443 }
444 else if(fcquantity>temp->quantity){
445 cls(); middle1();pre(3); printf("Out of Stock ! "); Sleep(2000);
446
447 goto foodlist;
448 }
449
450 middle1();pre(4); printf("Choice item %s its price is %0.2f \n\n",temp->foodname,temp->price*fcquantity);pre(4);
451 printf("1. Confirm to buy this \n\n");pre(4);
452 printf("2. Item List \n\n");
453 printf("Press 1 to confirm and 2 to back to list :");
454
455 confirm:
456 int confirm;
457
458 fflush(stdin); scanf("%d",&confirm);
459
460 if(confirm == 1 ){
461
462 br(2);pre(4);
463 printf(" 1. Cash ");
464 br(2);pre(4);
465 printf(" 2. Credit\n");
466 printf("Select Method Of payment 1-2: ");
467 payment:
468 int payment;
469
470 fflush(stdin); scanf("%d",&payment);
471
472 if(payment==1){
473
474
475 totalmoney += temp->price*fcquantity;
476 order++;
477 total_order[order]=get_food_choice;
478 order_quantity[order]=fcquantity;
479 uquantity = temp->quantity - fcquantity;
480
481 updatefood(get_food_choice,uquantity);
482
483
484 cls();middle1();pre(4); printf("===>THANK YOU<===");
485 br(2);pre(4); printf("Item Ordered Successfully ...");
486 br(2);pre(4); printf("1. Wanna Buy Another Delicious Food ? ");
487 br(2);pre(4); printf("2. Main Menu \n");
488 br(2);pre(4); printf("Select: ");
489 psmenu:
490 int ps_menu;
491
492 fflush(stdin); scanf("%d",&ps_menu);
493
494 if(ps_menu==1){goto foodlist;}
495 else if(ps_menu==2){goto mainmenu;}
496 else{br(2);pre(4);printf("Please Choice from list : "); goto psmenu;}
497
498 }
499
500 ///Credit Card Option
501
502 else if(payment==2){
503
504 int card_number[100];
505
506 c++;
507
508 cls();middle1();pre(4); printf("Enter Your Card No : ");
509
510 fflush(stdin); scanf("%d",&card_number[c]);
511
512
513
514 cardno[c] = card_number[c];
515
516 int pin;
517
518 br(2);pre(2); printf("Enter Your Card Pin [we never save your pin] : ");
519
520 fflush(stdin); scanf("%d",&pin);
521
522 cardmoney[c] = temp->price*fcquantity;
523
524 totalmoney += temp->price*fcquantity;
525 order++;
526 total_order[order]=get_food_choice;
527 order_quantity[order]=fcquantity;
528
529 uquantity = temp->quantity - fcquantity;
530
531 updatefood(get_food_choice,uquantity);
532
533 br(2);pre(4); printf("Payment Success...");
534 br(2);pre(4); printf("1. Wanna Buy Another Delicious ? ");
535 br(2);pre(4); printf("2. Main Menu \n");
536 br(2);pre(4); printf("select: ");
537 psmenu2:
538 int ps_menu2;
539
540 scanf("%d",&ps_menu2);
541
542 if(ps_menu2==1){goto foodlist;}
543 else if(ps_menu2==2){goto mainmenu;}
544 else{br(2);pre(4);printf("Please Choice from list : "); goto psmenu2;}
545
546 }
547
548 else{
549
550 br(2);pre(4); printf("Enter Choice from List : ");
551
552 goto payment;
553
554
555 }
556
557
558 } ///END Confirm Y/y
559
560
561
562 else if(confirm == 2){
563
564 goto foodlist;
565
566 }
567
568 else{
569 br(2);pre(4); printf("Enter Choice from List : ");
570
571 goto confirm;
572
573
574 } ///end confirm;
575
576
577 } ///end get food choice if line
578
579
580 else{
581
582 br(2);pre(4); echo("Please Choose From List "); br(2); Sleep(300);
583
584 goto foodlist;
585
586 } ///end get food choice
587 }
588
589 void cls(){
590
591 system("cls");
592
593 }
594
595 void echo(char print[]){
596
597 printf("%s",print);
598 }
599
600 void br(int line){
601 for(int i=0; i<line;i++){
602 printf("\n");
603 }
604 }
605
606 void pre(int tab){
607
608 for(int i=0; i<tab;i++){
609 printf("\t");
610 }
611
612 }
613 void span(int space){
614
615 for(int i=0; i<space;i++){
616 printf(" ");
617 }
618
619 }
620
621 void main_menu(){
622
623 cls();
624 br(5); pre(3); echo(">> 1. View Food List"); Sleep(400);
625 br(2); pre(3); echo(">> 2. Admin Panel"); Sleep(400);
626 br(2); pre(3); echo(">> 3. Exit"); Sleep(400);
627 // br(2); pre(3); echo("=> 4. Admin Panel"); Sleep(400);
628
629 br(1);
630
631 }
632
633 void insertend(int data, char foodname[25], int quantity, float price){
634
635 node *temp;
636
637 temp=(node *)malloc(sizeof(node));
638
639 temp->data = data;
640
641 temp->price = price;
642
643 temp-> quantity = quantity;
644
645 strcpy(temp->foodname,foodname);
646
647 temp->next = NULL;
648
649
650 if(head==NULL){
651 head = temp;
652 list = head;
653 }
654 else{
655
656 while(head->next != NULL){
657 head = head->next;
658 }
659
660 head->next = temp;
661 }
662
663 }
664
665 void insertfirst(int data, char foodname[25], int quantity, float price){
666
667 node *temp;
668
669 temp=(node *)malloc(sizeof(node));
670
671 temp->data = data ;
672
673 temp->price = price;
674
675 strcpy(temp->foodname,foodname);
676
677 temp-> quantity = quantity;
678
679
680 temp->next = head;
681
682 head = temp;
683
684 list = head ;
685
686 }
687
688 void insertmid(int pos, int data, char foodname[25], int quantity, float price){
689
690 node *temp;
691
692 temp=(node *)malloc(sizeof(node));
693
694 temp->data = data;
695
696 temp->price = price;
697
698 temp-> quantity = quantity;
699
700 strcpy(temp->foodname,foodname);
701
702 while(head->next->data != pos ){
703
704
705 head = head->next ;
706
707 }
708
709 temp->next = head->next;
710 head->next = temp ;
711
712 // free(temp);
713 }
714
715 void deletefood(int serial){
716
717 node *temp;
718 temp=(node *)malloc(sizeof(node));
719
720 temp = list;
721
722
723 if(temp->data != serial){
724
725 while(temp->next->data != serial){
726 temp = temp->next;
727 }
728
729 if(temp->next->data == serial){
730
731 temp->next = temp->next->next;
732 cls();
733 printf("\n\n\n\n\t\t\tDeleting Item %d ",serial);for(int cs=0;cs<4;cs++){printf(" .");Sleep(400);}
734
735 printf("\n\n\n\n\t\t\tDeleted Successfully \n"); Sleep(500);
736
737 }
738 else{
739 printf("\n\n\n\n\t\t\tCoffee Item Not Found\n"); Sleep(500);
740 }
741
742 head = temp ;
743
744 }
745 else{
746
747 temp = temp->next;
748 cls();
749 printf("\n\n\n\n\t\t\tDeleting Item %d ",serial);for(int cs=0;cs<4;cs++){printf(" .");Sleep(400);}
750
751 printf("\n\n\n\n\t\t\tDeleted Successfully \n"); Sleep(500);
752
753 head = temp ;
754
755 list=head;
756 }
757 }
758
759 void updatefood(int udata, int uquantity){
760
761 node *temp;
762 temp = list;
763
764 while(temp->data!=udata){
765 temp = temp->next;
766
767 }
768 if(temp->data == udata){
769 temp->quantity = uquantity;
770 }
771
772 }
773
774 int countitem(){
775
776 node *temp;
777
778 temp = list;
779
780 int countitem=0;
781
782 if(temp==NULL){
783 countitem = 0;
784 }
785 else{
786 countitem = 1;
787 while(temp->next != NULL){
788 countitem++;
789 temp = temp->next;
790 }
791
792 }
793
794
795 return countitem;
796
797 }
798 void foodlist(){
799
800 ccolor(0);
801
802 printf("\n\t\t"); ccolor(240);
803 printf("______________________________________________________ ");ccolor(26);
804 printf("\n\t\t"); ccolor(240);
805 printf("| Item No. | Item Name | Price | In Stock |");ccolor(26);
806 printf("\n\t\t"); ccolor(240);
807 printf("-------------------------------------------------------");ccolor(26);
808
809 node *temp;
810
811 temp = list;
812
813 while(temp != NULL){
814
815 ccolor(26);
816
817
818 printf("\n\t\t"); ccolor(62);
819 printf("| %d | %s | %0.2f | %d |",temp->data,temp->foodname, temp->price, temp->quantity);
820 ccolor(26);
821 printf("\n\t\t"); ccolor(62);
822 printf("-------------------------------------------------------");
823
824
825 temp = temp->next ;
826
827 Sleep(100);
828
829 }
830
831 ccolor(26);
832
833 // free(temp);
834
835 }
836
837
838 void order_view(int order, int quantity, int or_no){
839
840
841
842 ccolor(26);
843
844 node *temp;
845
846 temp = list;
847
848 while(temp->data != order){
849
850 temp = temp->next;
851
852 }
853 if(temp->data == order){
854
855 ccolor(26);
856
857 printf("\n\t\t"); ccolor(62);
858 printf("| %d | %s | %d | %d |",or_no,temp->foodname,quantity,temp->quantity);
859 ccolor(26);
860 printf("\n\t\t"); ccolor(62);
861 printf("-------------------------------------------------------");
862
863 Sleep(100);
864
865 }
866
867 ccolor(26);
868
869 }
870
871 void ccolor(int clr){
872
873 HANDLE hConsole;
874 hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
875 //SetConsoleTextAttribute(hConsole, clr);
876
877 //the above code displays colorful background. if you want colorful then you can remove the above comment but not the code, only comment//
878 }
879
880
881 ///HEERE PRINTF STYLE FUNCTION
882
883 void pwellcome(){
884 ccolor(26);
885
886 char welcome[50]="WELCOME";
887 char welcome2[50]=" TO";
888 char welcome3[50]=" DELICIOUS FOOD";
889 char welcome4[50]=" ORDER SYSTEM";
890 printf("\n\n\n\n\n\t\t\t");
891 for(int wlc=0; wlc<strlen(welcome);wlc++){
892
893 printf(" %c",welcome[wlc]);
894 Sleep(100);
895 }
896 ccolor(26);
897 printf("\n\n\t\t\t\t ");
898 for(int wlc2=0; wlc2<strlen(welcome2) ;wlc2++){
899
900 printf(" %c",welcome2[wlc2]);
901 Sleep(100);
902 }
903 ccolor(26);
904 printf("\n\n\n\t\t\t ");
905 for(int wlc3=0; wlc3<strlen(welcome3) ;wlc3++){
906 if(welcome3[wlc3]!='D'){
907
908 printf(" %c",welcome3[wlc3]);
909 }
910 else{
911
912 printf(" %c",welcome3[wlc3]);
913 }
914
915 Sleep(100);
916 }
917 ccolor(26);
918 printf("\n\n\n\t\t\t\t ");
919 for(int wlc3=0; wlc3<strlen(welcome4) ;wlc3++){
920 if(welcome4[wlc3]!='A' && welcome4[wlc3]!='E'){
921
922 printf(" %c",welcome4[wlc3]);
923 }
924 else{
925
926 printf(" %c",welcome4[wlc3]);
927 }
928 Sleep(100);
929 }
930 ccolor(26);
931
932 }
933 void loadingbar(void){
934
935 for (int i=15;i<=100;i+=5){
936
937 cls();
938
939 printf("\n\n\n\n\n\n\n\t\t\t\t");
940 printf("%d %% Loading...\n\n\t\t",i);
941
942 printf("");
943
944 for (int j=0; j<i;j+=2){
945
946 ccolor(160+j);
947 printf(" ");
948 ccolor(26);
949
950 }
951 Sleep(100);
952 if(i==90 || i==50 || i==96 || i==83){
953 Sleep(100);
954 }
955
956 }
957
958 }
959 void backuploader(void){
960
961 for (int i=15;i<=100;i+=5){
962
963 cls();
964 ccolor(26);
965
966 printf("\n\n\n\n\n\n\n\t\t\t\t");
967 printf("%d %% Backing UP DATA...\n\n\t\t",i);
968
969 printf("");
970
971 for (int j=0; j<i;j+=2){
972
973 ccolor(120+j);
974 printf(" ");
975 ccolor(26);
976
977 }
978 Sleep(50);
979 if(i==90 || i==50 || i==96 || i==83){
980 Sleep(50);
981 }
982 }
983
984 }
985
986
987 void middle1(void){
988
989 printf("\n\n\n\n\n\n\n");
990 }
991
992 void middtab1(void){
993 printf("\t\t\t\t\t");
994 }